<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>卡拉卡-在线选号平台</title>
		<link href="/css/style.css" rel="stylesheet" type="text/css" />
		<link href="/css/win.css" rel="stylesheet" type="text/css" />
		<script src="js/win.js" language="javascript" type="text/javascript"></script>
		<script type="text/javascript" src="../js/jquery-1.7.min.js"></script>
		<script type="text/javascript" src="../js/jquery.pagination.js"></script>
		<script type="text/javascript" src="../js/jquery.cookie.js"></script>
		<script type="text/javascript" src="../js/logon.js"></script>
		<script type="text/javascript" src="../js/jquery.blockUI.js"></script>
		<script type="text/javascript" src="../js/datepicker/WdatePicker.js"></script>
		<script type="text/javascript" src="../js/jquery.qtip-1.0.0-rc3.min.js"></script>
		<script language="javascript" type="text/javascript">
			$(document).ready(function() {
				$.ajax({
					type:"POST",
					dataType:"text",
					url:"/admin/report/agent", //提交到一般处理程序请求数据
					data:{aid:'$!{model.get("aid")}',st:'$!{model.get("st")}',et:'$!{model.get("et")}'}, //提交两个参数：pageIndex(页面索引)，pageSize(显示条数)
					success:function(data){
						var obj = jQuery.parseJSON(data);  
							$('#list-content-a').html('');
							$('#list-content-a').html(obj.a);
							$('#list-content-b').html('');
							$('#list-content-b').html(obj.b);
							$('#list-content-c').html('');
							$('#list-content-c').html(obj.c);
					},
			        error: function(){  //失败
				        alert('Error loading document');
				    }
				});
			});
			function tab(index)
			{
				if(index=="a")
				{
					$("#l_a").removeClass().addClass("tab_a");
					$("#l_b").removeClass().addClass("tab_b");
					//$("#l_c").removeClass().addClass("tab_b");
					$("#t_a").css("display","");
					$("#t_b").css("display","none");
					//$("#t_c").css("display","none");
				}
				if(index=="b")
				{
					$("#l_b").removeClass().addClass("tab_a");
					$("#l_a").removeClass().addClass("tab_b");
					//$("#l_c").removeClass().addClass("tab_b");
					$("#t_b").css("display","");
					$("#t_a").css("display","none");
					//$("#t_c").css("display","none");
				}
				//if(index=="c")
				//{
				//	$("#l_c").removeClass().addClass("tab_a");
				//	$("#l_a").removeClass().addClass("tab_b");
				//	$("#l_b").removeClass().addClass("tab_b");
				//	$("#t_c").css("display","");
				//	$("#t_a").css("display","none");
				//	$("#t_b").css("display","none");
				//}
			}
			
			//时间类型切换
			function doChange(obj)
			{
				$.ajax({    
			        type:'post',
			        url:'/common/datetype',
			        data:{dateType:obj.value},
			        cache:false,
			        async:false,
			        dataType:'json',
			        success:function(data){
			        	var d = jQuery.parseJSON(data);
			        	$("#st").val(data.st);
			        	$("#et").val(data.et);
			        },
			        error: function(){  //失败
				        alert('Error loading document');
				    }
			    });  
			}
			
			function stat()
			{
				$("#reportForm").submit();
			}
		</script>
	</head>

	<body>
		#include("header.html")
		<table width="100%" border="0" cellspacing="0" cellpadding="0" id="content">
			<tr><td valign="top" id="menu">
			#include("menu_admin.html")
			</td>
			<td valign="top" id="right">
				<div id="order">
					<div class="title">
						<span>首页 &gt; 销售分析</span>
					</div>
					<div class="step">
						<form id="reportForm" name="reportForm" action="/admin/report" method="post">
						代理商：
						<select name="aid">
							<option value="-1">全部</option>
							#foreach( $!{agent} in $!model.get("list") )
							<option value="$!{agent.aid}" #if($!{model.get("aid")}==$!{agent.aid}) selected #end>$!{agent.name}</option>
							#end
						</select>
						时间范围
						<select name="dateType" onChange="doChange(this);">
						  <option value="today" #if($!{model.get("dateType")}=="today") selected #end>今天</option>
						  <option value="yestday" #if($!{model.get("dateType")}=="yestday") selected #end>昨天</option>
						  <option value="week" #if($!{model.get("dateType")}=="week") selected #end>本周</option>
						  <option value="oneWeek" #if($!{model.get("dateType")}=="oneWeek") selected #end>一周内</option>
						  <option value="month" #if($!{model.get("dateType")}=="month") selected #end>本月</option>
						  <option value="oneMonth" #if($!{model.get("dateType")}=="oneMonth") selected #end>一月内</option>
						  <option value="period" #if($!{model.get("dateType")}=="period") selected #end>时间段</option>
						</select>
						<input type="text" id="st" name="st" value="$!{model.get("st")}" class="Wdate" style="height:20px" onfocus="WdatePicker();"/>-
						<input type="text" id="et" name="et" value="$!{model.get("et")}" class="Wdate" style="height:20px" onfocus="WdatePicker();"/>
						
						<input type="button" name="Submit" value="统计" class="out_btn" onclick="stat();"/>
						</form>
					</div>
					
				</div>
				<div id="list">
					<div class="tab">
						<a href="#" onclick="tab('a');"><span id="l_a" class="tab_a">按代理商统计</span></a>
						<a href="#" onclick="tab('b');"><span id="l_b" class="tab_b">按门店统计</span></a>
						<!-- <a href="#" onclick="tab('c');"><span id="l_c" class="tab_b">C计划（超长本地通话）</span></a> -->
					</div>
					<div id="t_a" class="data">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<thead>
							<tr style="font-size:14px;color:#333;">
								<td width="90">名称</td>
								<td width="60">运营商</td>
								<td width="90">总金额</td>
								<td width="60">折扣金额</td>
								<td width="150">订单数</td>
							</tr>
							</thead>
							<tbody id="list-content-a">
							</tbody>
						</table>
					</div>
					<div id="t_b" class="data" style="display:none">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<thead>
							<tr style="font-size:14px;color:#333;">
								<td width="90">套餐名称</td>
								<td width="60">套餐月费</td>
								<td width="90">国内主叫国内</td>
								<td width="60">数据流量</td>
								<td width="150">国内主叫（超出部分）</td>
							</tr>
							</thead>
							<tbody id="list-content-b">
							</tbody>
						</table>
					</div>
					<!-- 
					<div id="t_c" class="data" style="display:none">
						<table width="100%" border="0" cellspacing="0" cellpadding="0">
							<thead>
							<tr style="font-size: 14px; color: #333;">
								<td width="90">套餐名称</td>
								<td width="60">套餐月费</td>
								<td width="90">国内主叫国内</td>
								<td width="60">数据流量</td>
								<td width="150">国内主叫（超出部分）</td>
							</tr>
							</thead>
							<tbody id="list-content-c">
							</tbody>
						</table>
					</div> -->
				</div>
				</td></tr></table>
		#include("footer.html")
	</body>
</html>
